﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using LogicBaseLibrary.Zip;
using System.IO;

namespace CompressTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog fbd = new FolderBrowserDialog();
            fbd.SelectedPath = this.textBox1.Text;
            fbd.ShowDialog();
            this.textBox1.Text = fbd.SelectedPath;
            string[] files = Directory.GetFiles(this.textBox1.Text);
            foreach (string s in files)
                this.listView1.Items.Add(s);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();
            sfd.ShowDialog();
            this.textBox2.Text = sfd.FileName;
        }

        private void button3_Click(object sender, EventArgs e)
        {
            cZip c = new cZip(this.textBox1.Text, this.textBox2.Text);
            c.Compress();
            c.Close();
        }

        private void button4_Click(object sender, EventArgs e)
        {
            cZip c = new cZip(this.textBox3.Text);
            c.DeCompress(this.textBox4.Text);
            c.Close();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button3_Click_1(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "ZipFile(*.zip)|*.zip";
            ofd.ShowDialog();
            this.textBox3.Text = ofd.FileName;
            cZip c = new cZip(this.textBox3.Text);
            string[] files = c.GetFiles().Split(new char[] { '\r' });
            this.listView2.Items.Clear();
            foreach (string s in files)
            {
                string[] items = s.Split(new char[] { ',' });
                ListViewItem lvi = new ListViewItem(items);
                this.listView2.Items.Add(lvi);
            }
            c.Close();
        }

        private void button5_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog fbd = new FolderBrowserDialog();
            fbd.SelectedPath = this.textBox4.Text;
            fbd.ShowDialog();
            this.textBox4.Text = fbd.SelectedPath;
        }
    }
}
